import pos from "./pos";
import mp from "./mp";
import myEnv from "./env";
import params from "./params";

export default {
  ...pos,
  ...mp,
  ...myEnv,
  ...params,
  getRect(page, id) {
    return new Promise((resolve) => {
      uni
        .createSelectorQuery()
        .in(page)
        .select(id)
        .boundingClientRect(resolve)
        .exec();
    });
  },
  scrollToTop(scrollTop = 0, duration = 0) {
    uni.pageScrollTo({
      scrollTop,
      duration,
    });
  },
  share(opts = {}, scene = "WXSceneSession") {
    return new Promise((resolve, reject) => {
      uni.share({
        provider: "weixin",
        scene,
        type: 0,
        ...opts,
        success: resolve,
        fail: reject,
      });
    });
  },

  openSetting() {
    // #ifdef MP
    return new Promise((success) => {
      uni.openSetting({
        withSubscriptions: true,
        success, // { authSetting }
      });
    });
    // #endif
  },
};
